import Common
import Network
import Data.List
import System.IO (hSetBuffering, hPutStrLn, hGetLine, BufferMode(..), Handle)
import System (getArgs)

main :: IO()
main = withSocketsDo $ do
  args <- getArgs
  let port = fromIntegral (read $ head args :: Int)
  sock <- listenOn $ PortNumber port
  putStrLn $ "Listening on " ++ show port
  (handle, hostName, portNumber) <- accept sock
  hSetBuffering handle NoBuffering
  hPutStrLn handle $ show tree
  sClose sock




